def sortColumns(matrix): # DO NOT modify this line 
    trans_matrix=list(map(list,zip(*matrix)))
    sorted_matrix=[sorted(row) for row in trans_matrix]
    result_matrix=list(map(list,zip(*sorted_matrix)))
    return result_matrix# You can modify or delete this line

# === DO NOT modify the code below === 
def main():
    mx1 = []
    n = int(input())
    for i in range(n):
        numbers = [ eval(x) for x in input().split() ]
        mx1.append(numbers)
    mx2 = sortColumns(mx1)
    for row in mx2:
        print(" ".join(map(str,row)))
    
if __name__ == "__main__":
    main()
# === DO NOT modify the code above ===